﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.IO;
using blog;
namespace blog.Class
{
    public abstract class PageProxy : System.Web.UI.Page
    {
        [WebMethod]
        public static string RenderUserControl(string postid, string action)
        {
            if (action == "getlist")
            {
                Page page = new Page();
                UserControl.PostList postlist = (UserControl.PostList)page.LoadControl("/UserControl/PostList.ascx");
                postlist.setid(Convert.ToInt32(postid));
                page.Controls.Add(postlist);
                StringWriter writer = new StringWriter();
                HttpContext.Current.Server.Execute(page, writer, false);
                return writer.ToString();
            }
            else if (action == "getedit")
            {
                Page page = new Page();
                UserControl.EditPost editpost = (UserControl.EditPost)page.LoadControl("/UserControl/EditPost.ascx");
                editpost.setid(Convert.ToInt32(postid));
                page.Controls.Add(editpost);
                StringWriter writer = new StringWriter();
                HttpContext.Current.Server.Execute(page, writer, false);
                return writer.ToString();
            }
            else
            {
                return "";
            }
        }

    }
}


